package com.example.moviepro.mapper;


import com.example.moviepro.entity.Movie;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MovieMapper {
    @Insert("INSERT INTO Movie(title, director, description, posterUrl) values (#{title}, #{director},#{description},#{posterUrl})")
    void addMovie(Movie movie);


    @Select("select * from Movie where title = #{title}")
    Movie findMovie(Movie movie);


    @Select("select id from Movie where title = #{title}")
    int findMovieId(Movie movie);


    @Select("select * from Movie where id = #{id}")
    Movie findMovieById(int id);

    @Delete("delete from Movie where id = #{id}")
    void deleteMovie(int id);

    @Select("select * from Movie")
    List<Movie> getAllMovies();


    @Update("update Movie Set posterUrl=#{posterUrl} where id = #{id}")
    void updatePosterUrl(String posterUrl,int id);

    @Select("select posterUrl from Movie where id = #{id}")
    String findFilenameByid(int id);
}
